package com.xxx.user.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xxx.common.base.bo.ListResult;
import com.xxx.user.dao.mapper.OrderMapper;
import com.xxx.user.domain.entity.OrderDO;
import com.xxx.user.dto.OrderGetAllReqDTO;
import com.xxx.user.dto.OrderGetAllResDTO;
import com.xxx.user.service.OrderService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;


@Slf4j
@Service
@AllArgsConstructor
public class OrderServiceImpl implements OrderService {

    private final OrderMapper orderMapper;
    
    @Override
    public ListResult<OrderGetAllResDTO> getAll(OrderGetAllReqDTO param) {

        List<OrderDO> orderDOS = orderMapper.selectList(new LambdaQueryWrapper<OrderDO>()
                .in(param.getUserId() != null, OrderDO::getUserId, param.getUserId())
                .eq(param.getOrderStatus() != null, OrderDO::getOrderStatus, param.getOrderStatus()));

        List<OrderGetAllResDTO> orderGetAllResDTOS = BeanUtil.copyToList(orderDOS, OrderGetAllResDTO.class);

        ListResult<OrderGetAllResDTO> result = new ListResult<>();
        result.setList(orderGetAllResDTOS);
        result.setTotalNum(999);
        return result;
    }

}




